//
//  CellOfRootCVCVideo.m
//  To Feel
//
//  Created by 曹宇 on 16/7/14.
//  Copyright © 2016年 caoyu. All rights reserved.
//

#import "CellOfRootCVCVideo.h"
#import "Masonry.h"
#import "ModelOfFirstCVC.h"
#import "UIImageView+WebCache.h"
@interface CellOfRootCVCVideo ()
@property(nonatomic, retain) UIImageView *imgOfBackground;
@property(nonatomic, retain) UILabel *labelOfTitle;
@property(nonatomic, retain) UIView *viewOfImg; // img 加暗度
@end

@implementation CellOfRootCVCVideo
- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        [self creatSubview];
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}



- (void)setModel:(ModelOfFirstCVC *)model {
    
    NSURL *url = [NSURL URLWithString:[model.data objectForKey:@"image"]];
    [self.imgOfBackground sd_setImageWithURL:url placeholderImage:nil];
    
    self.labelOfTitle.text = [model.data objectForKey:@"title"];
    
}

- (void)creatSubview {
    
    self.imgOfBackground = [[UIImageView alloc] init];
    [self.contentView addSubview:self.imgOfBackground];
    
    [self.imgOfBackground mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(self);
    }];
    
    self.viewOfImg = [[UIView alloc] init];
    
    [self.contentView addSubview:self.viewOfImg];
    
    [self.viewOfImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(self.imgOfBackground);
    }];
    
    self.labelOfTitle = [[UILabel alloc] init];
    
    [self.contentView addSubview:self.labelOfTitle];
    
    [self.labelOfTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.centerY.equalTo(self);
    }];
    
    self.labelOfTitle.textColor = [UIColor whiteColor];
    self.labelOfTitle.font = [UIFont systemFontOfSize:16 weight:1];
    self.viewOfImg.backgroundColor = [UIColor colorWithRed:38 / 255.0 green:38 / 255.0 blue:38 / 255.0 alpha:0.2];
    
}

@end
